// ignore_for_file: must_be_immutable, prefer_typing_uninitialized_variables
import 'package:flutter/material.dart';

class InputTextView extends StatefulWidget {
  InputTextView(
      {super.key,
      required this.inputDoneCallBack,
      this.hintText = '想说点什么...',
      this.backGroundColor = const Color.fromRGBO(245, 245, 245, 1),
      this.maxLength = 200,
      this.maxLine = 5});
  String hintText;
  Color backGroundColor;
  int maxLength;
  int maxLine;
  var inputDoneCallBack;
  @override
  State<InputTextView> createState() => _InputTextViewState();
}

class _InputTextViewState extends State<InputTextView> {
  TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Container(
      color: widget.backGroundColor,
      padding: const EdgeInsets.fromLTRB(14, 10, 14, 10),
      child: TextField(
        textInputAction: TextInputAction.done,
        onSubmitted: (content) {
          // print('content:${controller.text}');
          widget.inputDoneCallBack(controller.text);
        },
        // onChanged: (content) {
        //   print('content:$content');

        //   widget.inputDoneCallBack(content);
        // },
        controller: controller,
        maxLength: widget.maxLength,
        maxLines: widget.maxLine,
        decoration: InputDecoration(
            hintText: widget.hintText,
            hintStyle: const TextStyle(
                fontSize: 16, color: Color.fromRGBO(119, 119, 119, 1)),
            border: InputBorder.none),
      ),
    );
  }
}
